package top.tagao.m02_creationalPatterns.c_03_prototype.service;

import top.tagao.m02_creationalPatterns.c_03_prototype.entity.User;
import top.tagao.m02_creationalPatterns.c_03_prototype.service.Impl.CRUDUserImpl;

/**
 * @author fu-xiao-liu
 * @Date 2022/7/19 21:47
 */
public class Main {
    public static void main(String[] args) throws Exception {
        CRUDUser mybatis = new CRUDUserImpl();

        //十分危险
        //得到的是克隆体
        User zhangsan1 = mybatis.getUser("zhangsan");
        System.out.println("1==>"+zhangsan1);
        zhangsan1.setUsername("李四2.。。");
        System.out.println("zhangsan1自己改了："+zhangsan1);


        //得到的是克隆体
        User zhangsan2 = mybatis.getUser("zhangsan");

        System.out.println("2-->"+zhangsan2);

        //得到的是克隆体
        User zhangsan3 = mybatis.getUser("zhangsan");
        System.out.println("3-->"+zhangsan3);

        //得到的是克隆体
        User zhangsan4 = mybatis.getUser("zhangsan");
        System.out.println("4-->"+zhangsan4);

        System.out.println(zhangsan1 == zhangsan3);

    }
}
